#ifndef BC_WEIR_BASE_HPP
#define BC_WEIR_BASE_HPP

#include "boundaryCondition.hpp"
#include "sweSolverTypes_fwd.hpp"
#include "coordTransformer.hpp"
#include "fieldMemberMacros.hpp"

namespace hms
{


template<typename MeshType>
class Weir_base : public BoundaryCondition<MeshType>
{
public:
	using BaseType = BoundaryCondition<MeshType>;
	using Type = typename BaseType::Type;
	using BaseType::field;
	using BaseType::patch;

protected:
	FieldTransformer<MeshType> m_transformer;
	mutable Array1Xs m_dEdgeBuf;
	/* this doubles one pointer, but adds convenience */
	scalar m_cp {0};
	scalar m_alpha; // slope angle
	D_FIELD_MEMBER;
	V_FIELD_MEMBER;

protected:
	Weir_base() = default;

	Weir_base(
		Type bcType,
		Field<MeshType>& f,
		const BoundaryPatch& patch,
		const Field<MeshType>& d,
		const Field<MeshType>& v,
		scalar alpha
	);

public:
	void alpha(scalar);
	auto alpha() const -> scalar;

	void cp(scalar);
	auto cp() const -> scalar;

protected:
	auto dEdge() const -> const Array1Xs&;

	void updateBuffers(bool orthoOnly) const;

	D_FIELD_ACCESSORS
	V_FIELD_ACCESSORS

private:
	void computeDEdge() const;
};

} // namespace hms

#endif